< previous page page_200 next page >

Page 200
Since you will be using the ANSI entry point, this means the function expects a pointer to a NULL-terminated ANSI string, the contents of which will not be modified by the function.
The declaration will obviously be ByVal As String.
The lpVolumeNameBuffer parameter is identical except that the C character is missing from the type definition. This means the parameter is not a constant, so the string can be modified by the API function. Since the function can modify the contents of the string, it needs to know how large a string buffer is available.1 This information is passed to the function using the nVolumeNameSize parameter, which is declared ByVal As Long.
In the original puzzle, the nVolumeNameSize parameter is set to 0, so the function returns an error value indicating that more information is available.1 This parameter should be set to the length of the buffer, in this case 256 because the strings are initialized to 256 characters. In the actual solution, the nVolumeNameSize buffer is actually set to 255. Why? Because the Win32 API is often inconsistent as to whether the length includes the NULL terminating character or not. So as a matter of habit, it's always a good idea to make your buffer a byte or two larger than you need, just in case.
The same technique is used to define the lpFileSystemNameBuffer and nFileSystemNameSize parameters.
The lpVolumeSerialNumber, lpMaximumComponentLength, and lpFileSystemFlags parameters are declared as type LPDWORD. This parses out as follows:
LP =Long (far) pointer
DWORD =Unsigned double word or unsigned 32-bit value

To pass a numeric pointer to an API function, you must declare it by reference instead of ByVal. Remove the ByVal operators for each parameter.
And the Serial Number . . .
Take a look at the serial number as displayed in a DOS window in response to the Dir command:
D:\>dir
 Volume in drive D is D1P1
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
1 Under Windows 95, the error value indicates the file name is too long. The reason for this difference is a puzzle that is beyond the ability of this humble author to comprehend.

 
< previous page page_200 next page >